package view;
import java.util.Collection;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;

import javax.swing.WindowConstants;

import model.dtos.MesaDTO;
import model.dtos.SectorDTO;

import org.jdesktop.application.Action;
import org.jdesktop.application.Application;
import org.jdesktop.application.ApplicationActionMap;

import controllers.AdministracionController;

import javax.swing.SwingUtilities;



/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class SectorAlta extends javax.swing.JPanel {
	private JLabel jLabelSectorNombre;
	private JButton jButtonSectorCancelar;
	private JButton jButtonSector;
	private JTextField jTextFieldSectorNombre;
	private static SectorAlta frameSectorAltaInstancia;

	
	public SectorAlta() {
		super();
		initGUI();
	}
	
	private void initGUI() {
		try {
			{
				jLabelSectorNombre = new JLabel();
				this.add(jLabelSectorNombre);
				jLabelSectorNombre.setText("Nombre del Sector: ");
				jLabelSectorNombre.setBounds(29, 49, 136, 14);
			}
			{
				jTextFieldSectorNombre = new JTextField();
				this.add(jTextFieldSectorNombre);
				jTextFieldSectorNombre.setBounds(164, 42, 108, 18);
			}
			{
				jButtonSector = new JButton();
				this.add(jButtonSector);
				jButtonSector.setText("Guardar");
				jButtonSector.setBounds(84, 114, 81, 21);
				jButtonSector.setAction(getAppActionMap().get("Guardar"));
			}
			{
				jButtonSectorCancelar = new JButton();
				this.add(jButtonSectorCancelar);
				jButtonSectorCancelar.setText("Cancelar");
				jButtonSectorCancelar.setBounds(170, 114, 102, 21);
				jButtonSectorCancelar.setAction(getAppActionMap().get("actionCancelar"));
			}
			this.setSize(355, 192);
			this.setLayout(null);
			Application.getInstance().getContext().getResourceMap(getClass()).injectComponents(this);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	public static SectorAlta getInstancia() {
		if(frameSectorAltaInstancia==null){
			frameSectorAltaInstancia=new SectorAlta();
		}
		return frameSectorAltaInstancia;
	}
	
	@Action
	public void actionCancelar() {
		frameSectorAltaInstancia.setVisible(false);
	}
	
    /**
    * Returns the action map used by this application.
     * Actions defined using the Action annotation
     * are returned by this method
     */
	private ApplicationActionMap getAppActionMap() {
		return Application.getInstance().getContext().getActionMap(this);
	}
	
	@Action
	public void Guardar() {
		
		SectorDTO _sector=new SectorDTO();
		
		if (jTextFieldSectorNombre.getText() != null)
		{
			_sector.setNombre(jTextFieldSectorNombre.getText());
			AdministracionController.getInstancia().guardarSector(_sector);
		}
	}

}
